/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package forense.classes;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

/**
 *
 * @author Kate
 */
public class Leer {
    public static void main(String[] args) throws FileNotFoundException, IOException {
     String archivo;
        JFileChooser fc = new JFileChooser();

        //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int res = fc.showOpenDialog(fc);
        if (res == JFileChooser.APPROVE_OPTION) {
            InputStreamReader conexion = null;
            try {
                File archFile = fc.getSelectedFile();
                //obtengo ruta
                archivo = archFile.getAbsolutePath();
                System.out.println(archivo);
                FileReader fr = new FileReader(archFile);
                 BufferedReader lector = new BufferedReader(fr);
                String linea;
                while ((linea = lector.readLine())!=null) {
                    System.out.println(linea);
                    
                }
                fr.close();
            } catch (UnsupportedEncodingException ex) {
                Logger.getLogger(LeerImagen.class.getName()).log(Level.SEVERE, null, ex);
            } finally {
                try {
                    conexion.close();
                } catch (IOException ex) {
                    System.out.println("error: " + ex);
                    Logger.getLogger(LeerImagen.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            

        } else {
            JOptionPane.showMessageDialog(null, "Debe seleccionar un directorio");
        }
    }
}
